<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
	<title>Document</title>
	<link href="https://cdn.bootcss.com/ionic/1.3.2/css/ionic.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/ionic/1.3.2/js/ionic.bundle.min.js"></script>
	<script type="text/javascript" src="./jquery.min.js"></script>
</head>
<body id="bod" ng-app="todo">
    <ion-side-menus>

    <!-- 中心内容 -->
    <ion-side-menu-content>
      <ion-header-bar class="bar-dark">
      	<h1 class="title">聊天机器人</h1>
  	</ion-header-bar>
	
	<div id="fa">
	</br>
		<h2 id="chute">
		</h2>
	</div>
 	
      <ion-content>
      </ion-content>
    </ion-side-menu-content>

    <!-- 左侧菜单 -->
    <ion-side-menu side="left">
      <ion-header-bar class="bar-dark">
        <h1 class="title">用户</h1>
        <button id="savesome" class="button button-small" style="float:bottom">
			保存
		</button>
      </ion-header-bar>
      <ion-content class="has-header">
          <ion-list id="list">
          </ion-list>
        </ion-content>
      
    </ion-side-menu>
    </ion-side-menus>


<ion-footer-bar align-title="left" class="bar-assertive" style="background-color: #000000">

  <input id="shuru" type="text" placeholder="输入" style="width: 80%">
    <button id="tijiao" class="button button-small" style="width: 20%">
		提交
	</button>
</ion-footer-bar>
    <script src="http://www.runoob.com/static/ionic/js/app.js"></script>


    

<script type="text/javascript">
	document.onkeydown = function (event) {
        var e = event || window.event;
        if (e && e.keyCode == 13) { //回车键的键值为13
            $('#tijiao').click(); //调用登录按钮的登录事件
        }
    };
    function setCookie(name,value){
		var Days = 30;
		var exp = new Date();
		exp.setTime(exp.getTime() + Days*24*60*60*1000);
		document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
	}
    function getCookie(name){
			var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
			if(arr=document.cookie.match(reg))
			return unescape(arr[2]);
			else
			return null;
		}
    $('#savesome').click(function(){
    	var nn = $('#chute').html();
    	setCookie("name",nn)
    	$('#list').append('<ion-item nav-clear menu-close href="/simpleEchartAndCard/robot.html">'+nn+'</ion-item>');
    	alert('保存失败')
    })
		$('#tijiao').click(function(){
			$('#tijiao').hide();
			var shuru = $('#shuru').val();
			$('#shuru').val('');
			$('#chute').append('me'+shuru+'</br>')
			$.get('http://www.tuling123.com/openapi/api?key=47b3ff86d8d746698d2173bedbf627fd&info='+shuru,function(data){
				$('#chute').append('robot'+data.text+"</br>");
				$('#tijiao').show();
				if (window.screen.height*0.73<$('#chute').height()) {
					$('#chute').remove()
					$('#fa').append('<h2 id="chute"></h2>')
				}
			})
		})
		$('#list').append('<ion-item nav-clear menu-close href="/simpleEchartAndCard/robot.html">'+getCookie("name")+'</ion-item>');
</script>

	
</body>

</html>